package com.zmn.plat.services.impl.log;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zmn.plat.model.entity.log.LoginLogStaff;
import com.zmn.plat.model.entity.log.LoginLogStaffQuery;
import com.zmn.plat.persistence.interfaces.log.LoginLogStaffDao;
import com.zmn.plat.services.interfaces.log.LoginLogStaffService;

/**
 * @author nowind
 * @since 2017/9/16 19:32
 */
@Service
public class LoginLogStaffServiceImpl implements LoginLogStaffService {

    @Resource
    private LoginLogStaffDao loginLogStaffDao;

    @Override
    public LoginLogStaff findByKey(Integer logId) {
        return loginLogStaffDao.findByKey(logId);
    }

    @Override
    public List<LoginLogStaff> listPageByQuery(LoginLogStaffQuery query) {
        Integer count = this.countByQuery(query);
        query.setTotalCount(count);
        return count == 0 ? new ArrayList<>(0) : loginLogStaffDao.listPageByQuery(query);
    }

    @Override
    public Integer countByQuery(LoginLogStaffQuery query) {
        return loginLogStaffDao.countByQuery(query);
    }

    @Override
    public Integer insert(LoginLogStaff loginLogStaff) {
        int pos = loginLogStaffDao.insert(loginLogStaff);
        return pos > 0 ? loginLogStaff.getLogId() : 0;
    }
}
